package 力扣算法练习.main1.newPart1;

public class day9 {
    //https://www.nowcoder.com/practice/4284c8f466814870bae7799a07d49ec8?tpId=122&tqId=33674&ru=/exam/oj
    //时间复杂度太高不符合
    public void Step(int n ,int m){
        System.out.println(findStep(n, m, 0));
    }
    //进行递归判断
    private static int findStep(int n,int m,int step){
        if(n==m)return step;
        if(n>m)return -1;

        int temp,result=-1;
        for(int i=2;i<n;i++){
            if(findy(i,n)){
                temp= findStep(n+i,m,step+1);
                if(temp==-1){
                    return result;
                }
                if(result==-1){
                    result=temp;
                }
                if(temp!=-1&&temp<result){
                    result=temp;
                }
            }
        }
        return result;
    }


    //判断是不是约数
    private static boolean findy(int i,int n){
        if(n%i==0){
            return true;
        }
        return false;
    }
}
